class Solution {
    public:
        int minDeletion(string s, int k) {
            vector<int> arr(26);
            for(char c : s){
                arr[c - 'a']++;
            }
            sort(arr.begin(),arr.end());
            int ans = 0;
            for(int i = 0;i + k < 26;i++){
                ans += arr[i];
            }
            return ans;
        }
    };
    class Solution {
        public:
            bool canPartitionGrid(vector<vector<int>>& grid) {
                int m = grid.size(),n = grid[0].size();
            
                vector<long long> Vert__(m,0);
                vector<long long> Level(n,0);
                for(int i = 0;i < m;i++){
                    for(int j = 0;j < n;j++){
                        Vert__[i]  += grid[i][j];
                        Level[j] += grid[i][j];
                    }
                }
                long long left = 0,right = m - 1,sumleft = 0,sumright = 0;
                while(left <= right){
                    if(sumleft < sumright){
                        sumleft += Vert__[left];
                        left++;
                    }else{
                        sumright += Vert__[right];
                        right--;
                    }
                }
                if(sumleft == sumright) return true;
                
                left = 0,right = n - 1,sumleft = 0,sumright = 0;
                while(left <= right){
                    if(sumleft < sumright){
                        sumleft += Level[left];
                        left++;
                    }else{
                        sumright += Level[right];
                        right--;
                    }
                }
                if(sumleft == sumright) return true;
        
        
                return false;
            }
        };